package br.com.foxinline.servico;

import br.com.foxinline.generico.ServicoGenerico;
import br.com.foxinline.modelo.DadosIptu;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;

/**
 *
 * @author luciano
 */
@Stateless
public class DadosIptuServico extends ServicoGenerico<DadosIptu> {

    public DadosIptuServico() {
        super(DadosIptu.class);
    }

    public DadosIptu find() {
        return find(null);
    }

    @Override
    public DadosIptu find(Long entityID) {
        return findAll().get(0);
    }

    @Override
    public List<DadosIptu> findAll() {

        List<DadosIptu> results = super.findAll();

        if (results == null || results.isEmpty()) {
            results = new ArrayList<DadosIptu>();
            results.add(new DadosIptu());
            return results;
        }

        return results;
    }

    @Override
    public void save(DadosIptu entity) {
        entity.setDataGeracao(new Date());
        super.save(entity);
    }
}
